<?php
error_reporting(E_ALL ^ E_NOTICE);

set_time_limit(0);
$conn = @mysql_connect("localhost","root","root");
if (!$conn){
    die("Could not connect：" . mysql_error());
}

mysql_select_db("devildark", $conn);
mysql_query("set names 'UTF-8'"); 
 
$deviceid_query =  mysql_query("SELECT  deviceid,firstPayDate FROM report_nojailbreak_total where firstPayDate >'2012-03-01'");

while($deviceid = mysql_fetch_array($deviceid_query))
{
     //级别
    $money_query = mysql_query("SELECT count(1) FROM devildark WHERE date<='$deviceid[firstPayDate]' AND  deviceid = '$deviceid[deviceid]'");

    $money = mysql_fetch_array($money_query);

 
$sql = "UPDATE report_nojailbreak_total SET firstPayDay= '$money[0]' WHERE deviceid= '$deviceid[deviceid]'";

if(mysql_query($sql,$conn)){
    echo "1 update is ok!";
} else {
    echo "failed：".mysql_error();
}


}
?>
